#include <iostream>
#include <set>
#include <vector>
#include <cmath>
using namespace std;

static bool prime(uint64_t n) {
    if (n < 2) {
        return false;
    }
    if (n < 4) {
        return true;
    }
    if (n % 2 == 0) {
        return false;
    }
    for (uint64_t i = 3; i * i <= n; i += 2) {
        if (n % i == 0) {
            return false;
        }
    }
    return true;
}

int main() {
    constexpr uint64_t limit = 50'000'000;
    vector<uint64_t> primes {2};
    for (uint64_t i = 3; i <= sqrt(limit - 8 - 16); i += 2) {
        if (prime(i))
            primes.push_back(i);
    }
    cout << "Number of primes: " << primes.size() << endl;

    set<uint64_t> ans;
    for (auto& a : primes) {
        for (auto& b : primes) {
            auto t = a * a + b * b * b;
            if (t > limit)
                break;
            for (auto& c : primes) {
                auto s = t + c * c * c * c;
                if (s > limit)
                    break;
                else
                    ans.insert(s);
            }
        }
    }
    cout << ans.size() << endl;
}